<!-- 
  原理：用于检测构造函数的prototype属性是否出现在某个实列对象的原型链上
  要注意的是原型链，如果当前对象没有找到，就会沿着原型链一直往上寻找
 -->
 <!DOCTYPE html>
 <html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
 </head>
 <body>
  <script>
    function myInstanceOf(obj, constructor) {
      if(typeof obj !== "object" || obj === null) {
        return false
      }
      if(typeof constructor !== "function"){
        throw new Error("constructor must be function")
      }
      let _p = obj.__proto__
      while(_p !== null) {
        if(_p === constructor.prototype) {
          return true
        } else {
          _p = _p.__proto__
        }
      }
      return false
    }
    function myInstanceOf(obj, constructor) {
      let _p = obj.__proto__
      while(_p !== null){
        if(_p === constructor.prototype){
          return true
        } else {
          _p = obj.__proto__
        }
      }
      return false
    }
  </script>
 </body>
 </html>